﻿namespace System.ServiceModel.DomainServices.Client
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;

    internal class ValidationResultEqualityComparer : EqualityComparer<ValidationResult>
    {
        public override bool Equals(ValidationResult left, ValidationResult right)
        {
            return (left.ErrorMessage.Equals(right.ErrorMessage, StringComparison.Ordinal) && left.MemberNames.SequenceEqual<string>(right.MemberNames));
        }

        public override int GetHashCode(ValidationResult validationResult)
        {
            int hashCode = validationResult.ErrorMessage.GetHashCode();
            foreach (string str in validationResult.MemberNames)
            {
                hashCode ^= str.GetHashCode();
            }
            return hashCode;
        }
    }
}

